#######################################
# Zsh specific
#######################################
export LC_ALL=C
HISTFILE=~/.history
HISTSIZE=100000
SAVEHIST=100000
HOST=`/bin/uname -n`
setopt INC_APPEND_HISTORY SHARE_HISTORY HIST_IGNORE_DUPS HIST_IGNORE_SPACE HIST_NO_STORE NO_HIST_BEEP autocd prompt_subst AUTO_PUSHD PUSHD_IGNORE_DUPS
bindkey -e
bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
COLOR=gray
if [[ -f /etc/BA.conf ]]
then
	. /etc/BA.conf
	COLOR=green
	if [[ "$LAND" == "prd" ]] then COLOR=red; fi
	if [[ "$HOST" == "saprmt01" ]] || [[ "$HOST" == "saprmt02" ]]; then COLOR=yellow; fi
fi
fpath=( $fpath /opt/freeware/share/zsh/site-functions /opt/freeware/share/zsh/4.3.12/functions )
autoload -Uz colors 
#autoload -Uz colors promptinit
colors 
#colors promptinit
#autoload -Uz chpwd_recent_dirs cdr add-zsh-hook colors promptinit
#chpwd_recent_dirs cdr add-zsh-hook colors promptinit
if /bin/uname | /bin/grep -q Linux
then
	PS1="%B$fg[white](%b%n$fg[white]%B@$fg[$COLOR]%m$fg[white]:%~%B)%b$ "
else
	PS1="%B%F{white}(%b%F{reset}%n%F{white}%B@%b%F{$COLOR}%m%F{white}:%F{reset}%~%F{white}%B)%b$%F{reset} "
fi
#######################################
# Customization
#######################################
if [[ -f ~/.bash_aliases ]]; then . ~/.bash_aliases; fi
if [[ -f $SAPSCRIPTS/bash_aliases ]]; then . $SAPSCRIPTS/bash_aliases; fi
if [[ -f ~/.zaliases ]]; then . ~/.zaliases; fi
if [[ -f $SAPSCRIPTS/zaliases ]]; then . $SAPSCRIPTS/zaliases; fi
#######################################
# Set Window title for screen
#######################################
function title {
  if [ "$TERM" = "xterm" ] || [ "$TERM" = "rxvt" ]; then
    # Use this one instead for XTerms:
    print -nR $'\033]0;'$*$'\a'
  elif [ "$TERM" = "screen" ] || [ "$TERM" = "vt100" ]; then
    # Use these two for GNU Screen:
    print -nR $'\033k'$1$'\033'\\
    print -nR $'\033]0;'$2$'\a'
  fi
}
function precmd {
  title `/bin/uname -n` `/bin/uname -n`
}
#function preexec {
#  emulate -L zsh
#  local -a cmd; cmd=(${(z)1})
#  title $cmd[1]:t "$cmd[2,-1]"
#}
#######################################
if [ "$HOST" = "saprmt01" ] || [ "$HOST" = "saprmt02" ] && [ "$USER" != "root" ]; then agent_list; fi
#######################################
PATH=$PATH:/usr/local/scripts/ssh_hosts:/usr/local/scripts
# To fix ctrl-s problem in screen
# see: http://munkymorgy.blogspot.ca/2008/07/screen-ctrl-s-bug.html
stty ixany
